const mysql = require('mysql2/promise');
const {connection} = require('./common');
const fs = require('fs');
const path = require('path')

async function getPic(data){
    const file = data;
    const reader = fs.createReadStream(file.path);
    const str = __dirname.replace('\/modules','');
    const filePath = path.join(str,'images') + `\/${file.name}`;
    console.log(filePath);
    const upStream = fs.createWriteStream(filePath);
    reader.pipe(upStream)
    let realPath = `http://101.34.58.111:8081/images/${file.name}`
    return {Type:200,status:'上传成功',addr:realPath}
}
module.exports = {
    getPic
}
